/**
 * Created by dev-001 on 2017/2/28.
 * 学校
 */
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

const SchoolSchema = new Schema({
    name: String,
    address: String,
    avatar: String,
    postCode: String,
    telephone: String,
    type: Number,//公立私立培训机构
    master: Boolean,//主校还是分校
    group: {
        type: ObjectId,
        ref: 'Group'
    },
    createdAt: Date,
    updatedAt: Date
},{
    toObject: {
        virtuals: true
    },
    toJSON: {
        virtuals: true
    }
});

SchoolSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

export default mongoose.model('School', SchoolSchema);